//
//  DiscoverViewController.swift
//  Swift微博
//
//  Created by 陈竹 on 16/2/21.
//  Copyright © 2016年 陈竹. All rights reserved.
//

import UIKit
//定义可重用标识符
private let CZDiscoverCellID="CZDiscoverCellID"
class DiscoverViewController: RootViewController {

    override func viewDidLoad() {
        setupRefreshControl()
        super.viewDidLoad()
        //注册可重用cell
        tableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: CZDiscoverCellID)
        //添加访客视图
        visitorView?.setupInfo("visitordiscover_image_message",
            message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
       
    }

    override func loadData() {
        refreshControl?.beginRefreshing()
        let when=dispatch_time(DISPATCH_TIME_NOW, Int64(Double(NSEC_PER_SEC)*1.0))
        dispatch_after(when, dispatch_get_main_queue()) { () -> Void in
            
        }
        dataCount+=10
        self.refreshControl?.endRefreshing()
        self.pullUpView.stopAnimating()
        self.tableView?.reloadData()
        
    }
    private var dataCount=0
}
extension DiscoverViewController{
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataCount
        
    }
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell=tableView.dequeueReusableCellWithIdentifier(CZDiscoverCellID, forIndexPath: indexPath)
        cell.textLabel?.text="\(indexPath.row)"
        return cell
    }

}
